package com.tianyang.yukuaifu.module.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.tianyang.yukuaifu.R;
import com.tianyang.yukuaifu.base.BaseDialog;

/**
 * Description：联系客服dialog
 * Created by 薛勇军 on 2018/7/12.
 */

public class CallServiceDialog extends BaseDialog<CallServiceDialog> {
    private TextView close;
    private TextView ok;

    private TextView vContent;
    private TextView vTitle;
    private String title;
    private String content;

    private OnCallLinstener callLinstener;

    public CallServiceDialog content(String content) {
        this.content = content;
        return this;
    }

    public void setCallLinstener(OnCallLinstener callLinstener) {
        this.callLinstener = callLinstener;
    }

    public CallServiceDialog(Context context) {
        super(context);
    }

    @Override
    public View onCreateView() {
        showAnim(new BaseAnimatorSet() {
            @Override
            public void setAnimation(View view) {

            }
        });
        View inflate = View.inflate(getContext(), R.layout.dialog_call_service, null);
        vContent = inflate.findViewById(R.id.content);
        vTitle = inflate.findViewById(R.id.title);
        close = inflate.findViewById(R.id.close);
        ok = inflate.findViewById(R.id.ok);
        inflate.setPadding(dp2px(15), dp2px(15), dp2px(15), dp2px(15));

        if (!TextUtils.isEmpty(title)) {
            vTitle.setVisibility(View.VISIBLE);
            vTitle.setText(title);
        }
        return inflate;
    }

    @Override
    public void setUiBeforShow() {
        vContent.setText(content);
        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (callLinstener != null) {
                    callLinstener.OnClickListener();
                }
                dismiss();
            }
        });

    }

    public CallServiceDialog title(String title) {
        this.title = title;
        return this;
    }

    public interface OnCallLinstener {
        void OnClickListener();
    }
}